package com.m3u8.http;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

public class OKhttper {

    private static OkHttpClient okHttpClient;
    private static final int TIMEOUT = 60;

    public static OkHttpClient getOkhttpClient() {
        if (okHttpClient == null) {
            synchronized (OkHttpClient.class) {
                if (okHttpClient == null) {
                    okHttpClient = getOkHttpClient();
                }
            }
        }
        return okHttpClient;
    }

    private static OkHttpClient getOkHttpClient() {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        builder.connectTimeout(TIMEOUT, TimeUnit.SECONDS);
        builder.writeTimeout(TIMEOUT, TimeUnit.SECONDS);
        builder.readTimeout(TIMEOUT, TimeUnit.SECONDS);
        return builder.build();
    }
}
